package com.biancheng.biancheng.biancheng2;

import java.util.*;

public class 员工排序_调薪_职级高的排在前面2 {
    /**
     * 6
     * 张三 3 3 3000
     * 李四 3 4 3000
     * 王五 3 3 4000
     * 赵六 4 3 3000
     * 陆奇 4 4 4000
     * 闫八 4 4 3980

     * @param args
     */
    public static void main(String[] args) {
        Scanner  input=new Scanner(System.in);
        String temstr=input.nextLine();
        int n=Integer.parseInt(temstr);
        String [] table=new String[n];
        for(int i=0;i<n;i++){
            table[i]=input.nextLine();
        }
        List<Person> list=new ArrayList();
        for (int i=0;i<n;i++){
            String [] tem=table[i].split(" ");
            list.add(new Person(Integer.parseInt(tem[1]), Integer.parseInt(tem[2]), Double.parseDouble(tem
                    [3]),tem[0]));
        }
        //排序
        Collections.sort(list, new Comparator<Person>() {
            @Override
            public int compare(Person o1, Person o2) {
                return o1.compareTo(o2);
            }
        });
        for (int i = 0; i < list.size(); i++) {
            System.out.printf("%s %d %d %.2f\n",list.get(i).str,list.get(i).dj,list.get(i).nl,list.get
                    (i).gz);
        }
    }

}

class Person implements Comparable<Person>{
    public int dj,nl;
    public double gz;
    public String str;
    public Person(int dj,int nl,double gz,String str){
        this.dj=dj;
        this.nl=nl;
        this.gz=gz;
        this.str=str;
    }
    @Override
    public int compareTo(Person o) {
        if (this.dj < o.dj) {
            return 1;
        } else if ((this.dj == o.dj&&this.gz > o.gz)) {
            return 1;
        } else if ((this.dj == o.dj &&this.gz == o.gz&&this.nl<o.nl)) {
            return 1;
        } else if ((this.dj == o.dj&&this.gz== o.gz&&this.nl == o.nl)) {
            return 0;
        }else{
            return -1;
        }
    }
}